﻿using System;
using System.IO;
using System.Windows.Forms;


namespace Marmat.Forms
{
    internal partial class ErrorFormEx : Form
    {
        public ErrorFormEx(Exception ex)
        {

            // 此调用是设计器所必需的。
            this.InitializeComponent();

            // 在 InitializeComponent() 调用之后添加任何初始化。
            this.Exception = ex;
            this.TextBox1.Text = this.Exception.ToString();
            this.Label1.Text = string.Format(this.Label1.Text, new FileInfo(Application.ExecutablePath).Name);
            Button3.Name = "Button3";
        }

        private Exception Exception;

        /// <summary>
        /// 错误信息折叠状态
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        /// <remarks></remarks>
        public bool Expand
        {
            get
            {
                return this.m_Expand;
            }

            set
            {
                if (this.m_Expand != value)
                {
                    this.m_Expand = value;
                    this.Height = value ? 400 : 260;
                }
            }
        }

        private bool m_Expand = false;


        // ''' <summary>
        // ''' 发送错误报告
        // ''' </summary>
        // ''' <param name="sender"></param>
        // ''' <param name="e"></param>
        // ''' <remarks></remarks>
        // Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        // Dim Send As New BI.Client.SendException
        // Dim boo As Boolean = Send.SendException(My.Application.Info.AssemblyName, My.Application.Info.Version, Me.Exception)
        // If boo = False Then
        // MsgBox("发送失败！")
        // End If
        // Me.DialogResult = Windows.Forms.DialogResult.OK
        // End Sub

        /// <summary>
        /// 展开或者折叠错误信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private void Button3_Click(object sender, EventArgs e)
        {
            this.Expand = !this.Expand;
        }
    }
}